<?php

$tk->page->request = 'json';

$up = new ajaxupload($tk->config, $tk->eh, $tk->session, $lang['ajaxupload']['error'], false);

$_filename = 'Filedata';

$up->process_file($_filename);

/*
$_path = preg_replace('%[^\w-]%i', '', $_REQUEST['path']);
$_subpath = preg_replace('%[^\w-]%i', '', $_REQUEST['subpath']);
*/

$up->check_destination('temp');

$_filename = preg_replace('%[^\w-]%i', '', $_REQUEST['filename']);

$up->check_filename($_filename);

$up->process_upload();

// @todo !
/*
 


if ((int) $_REQUEST['resize'] == '1' && ! $tk->eh->_errorFlag)
{
	
	if (! in_array($up->file['extension'], array(
			'jpg', 
			'jpeg', 
			'gif', 
			'png')))
	{
		goto end;
	}
	
	$tmp = explode(';',$_REQUEST['params']);
	
	foreach($tmp as $par)
	{
		list($k,$v) = explode('=',$par);
		$params[$k] = $v;
	}
	unset($tmp);

	$source_file = $up->file['destination'].'/'.$up->file['basename'];
	
	if((int) $params['w'] && (int) $params['h'] )
	{
		$dest_suffix = '_'.$params['w'].'x'.$params['h'];
	}
	
	$dest_file = $up->file['destination'].'/thumbs/'.$up->file['filename'].$dest_suffix.'.png';

	$tk->f->generateThumbnail($tk->eh,$source_file,$dest_file,$params);
	
	$tk->eh->_result['thumbnail_src'] = '../../../'.$dest_file;
	
	$tk->eh->_result['image_src'] = $dest_file;
	
	if($_path)
	{
		$tk->eh->_result['save_dest'] = str_replace($_path.'/','',$dest_file);
	}
}
*/
end:

$data = json_encode($tk->eh->_result, true);